home *** CD-ROM | disk | FTP | other *** search
/ Nothing but Tetris / Nothing but Tetris.iso / amiga / wbtris_1.54 / source / statistic.c < prev    next >
C/C++ Source or Header  |  1988-10-06  |  3KB  |  117 lines

  1. #include "WBTRIS.h"
  2.  
  3. #define beveloff       50
  4.  
  5.  
  6. __chip UWORD tileData[] = {
  7.     0x0080,0x7F80,0x7F80,0x7F80,0x7F80,0x7F80,0x7F80,
  8.     0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0x8000,
  9. };
  10.  
  11. struct Image tile = {
  12.     0, 0,
  13.     9, 7, 2,
  14.     tileData,
  15.     0x0003, 0x0000,
  16.     NULL
  17. };
  18.  
  19. extern BOOL            UseLace;
  20. extern struct TextAttr helvetica13;
  21. extern struct TextAttr topaz8;
  22.  
  23.  
  24. void statistic(WORD WBTRIS_Window_Left, WORD WBTRIS_Window_Top, int ob1, int ob2, int ob3, int ob4, int ob5, int ob6, int ob7)
  25. {
  26.    extern APTR           VisualInfo;
  27.    extern struct Screen *myscreen;
  28.  
  29.    struct Window        *win = NULL;
  30.    int                   i;
  31.    double                max=0.0;
  32.    double                laenge;
  33.    double                objects[7];
  34.    struct IntuiText      Zeile;
  35.    char                  s[80];
  36.    double                summe = 0;
  37.  
  38.    objects[0] = ob2;
  39.    objects[1] = ob6;
  40.    objects[2] = ob7;
  41.    objects[3] = ob3;
  42.    objects[4] = ob4;
  43.    objects[5] = ob5;
  44.    objects[6] = ob1;
  45.  
  46.    Zeile.FrontPen = 1;
  47.    Zeile.BackPen = 0;
  48.    Zeile.DrawMode = JAM2;
  49.    Zeile.LeftEdge = 0;
  50.    Zeile.TopEdge = 0;
  51.    if (UseLace)
  52.       Zeile.ITextFont = &helvetica13;
  53.    else
  54.       Zeile.ITextFont = &topaz8;
  55.    Zeile.NextText = NULL;
  56.  
  57.    s[0] = '\0';
  58.  
  59.    if (win = OpenWindowTags(NULL,
  60.                             WA_Left,         WBTRIS_Window_Left,
  61.                             WA_Top,          WBTRIS_Window_Top+(myscreen->Font->ta_YSize)+3,
  62.                             WA_Width,        337,
  63.                             WA_Height,       265+(myscreen->Font->ta_YSize),
  64.                             WA_CloseGadget,  TRUE,
  65.                             WA_Title,        "<-- Click to close",
  66.                             WA_DragBar,      TRUE,
  67.                             WA_Activate,     TRUE,
  68.                             WA_Flags,        WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_WINDOWACTIVE,
  69.                             WA_IDCMP,        IDCMP_CLOSEWINDOW | IDCMP_RAWKEY,
  70.                             TAG_END)) {
  71.       DrawWin(win,VisualInfo);
  72.       for (i=0;i<7;i++) {
  73.          if (objects[i] > max)
  74.             max = objects[i];
  75.          summe = summe + objects[i];
  76.       }
  77.       if (summe == 0)
  78.          summe = 0.00000001;
  79.       if (max == 0)
  80.          max = 1;
  81.       for (i=0;i<7;i++) {
  82.          laenge = 172*objects[i]/max;
  83.          SetAPen(win->RPort,3);
  84.          RectFill(win->RPort, 72, 35*i+23+(myscreen->Font->ta_YSize), (short)(72+laenge), 35*i+34+(myscreen->Font->ta_YSize));
  85.          sprintf(s, "%5.1f%%", 100*objects[i]/summe);
  86.          Zeile.IText = s;
  87.          PrintIText(win->RPort, &Zeile, 255, 35*i+23+(myscreen->Font->ta_YSize));
  88.          s[0] = '\0';
  89.       }
  90.       WaitPort(win->UserPort);
  91.       CloseWindow(win);
  92.    }
  93. }
  94.  
  95.  
  96.  
  97. void DrawWin(struct Window *win,APTR  VisualInfo)
  98. {
  99.    int i,j;
  100.    extern struct obj {
  101.      BOOL objData[4][4];
  102.      int color;
  103.    };
  104.    extern struct obj objects[8];
  105.    short ObjNumber = 1;
  106.  
  107.    while (ObjNumber<=7) {
  108.       for (i=0;i<4;i++)
  109.          for (j=0;j<4;j++)
  110.             if (objects[ObjNumber].objData[j][i] == 1)
  111.                DrawImage(win->RPort,&tile,9*i+18,35*ObjNumber+7*j-20+(myscreen->Font->ta_YSize));
  112.       DrawBevelBox(win->RPort, 15 , 35*ObjNumber-22+(myscreen->Font->ta_YSize) , 43, 32 ,GTBB_Recessed, TRUE, GT_VisualInfo, VisualInfo);
  113.       DrawBevelBox(win->RPort, 70 , 35*ObjNumber-13+(myscreen->Font->ta_YSize) , 177, 14 ,GTBB_Recessed, TRUE, GT_VisualInfo, VisualInfo);
  114.       ObjNumber++;
  115.    }
  116. }
  117.